package com.example.tnot.Teacher.Homepart.adapter;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tnot.R;
import com.example.tnot.Teacher.Homepart.ItemBean.rv_HomeResourceListItem;

import java.util.ArrayList;
import java.util.List;

public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.ViewHolder>{
    List<rv_HomeResourceListItem> data = new ArrayList<>();

    public HomeAdapter(List<rv_HomeResourceListItem> data) {
        this.data = data;
    }

    @NonNull
    @Override
    public HomeAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_rv_home_recommend,parent, false);
        return new HomeAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull HomeAdapter.ViewHolder holder, int position) {
        holder.iv_ResImage.setImageResource(data.get(position).getResImage());
        holder.tv_Resmessage.setText(data.get(position).getResmessage());
        holder.tv_time.setText(data.get(position).getTime());
        holder.tv_see.setText(data.get(position).getSee());
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                NavController navController = Navigation.findNavController(v);

            }
        });
    }

    @Override
    public int getItemCount() {
        return data.size();
    }
    public static class ViewHolder extends RecyclerView.ViewHolder{
        ImageView iv_ResImage;
        TextView tv_time,tv_Resmessage,tv_see;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            iv_ResImage = itemView.findViewById(R.id.iv_ResImage);
            tv_Resmessage = itemView.findViewById(R.id.tv_Resmessage);
            tv_time = itemView.findViewById(R.id.tv_time);
            tv_see = itemView.findViewById(R.id.tv_see);
        }
    }
}
